
    <!DOCTYPE html>
    <html lang="zh-CN">
    <head>
      <meta charset="UTF-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <title>手动实现springboot自动装配 - 学习卡片</title>
      <style>
        body { font-family: sans-serif; background-color: #f0f8ff; color: #333; display: flex; flex-direction: column; align-items: center; padding: 50px 20px; }
        .header h1 { font-size: 32px; }
        .grid-container { display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; width: 100%; max-width: 1200px; }
        .card-container { perspective: 1200px; cursor: pointer; height: 250px; }
        .card { width: 100%; height: 100%; position: relative; transform-style: preserve-3d; transition: transform 0.7s; border-radius: 16px; box-shadow: 0 4px 16px rgba(0,0,0,0.08); }
        .card-container.flipped .card { transform: rotateY(180deg); }
        .card-face { position: absolute; width: 100%; height: 100%; backface-visibility: hidden; display: flex; flex-direction: column; box-sizing: border-box; border-radius: 16px; background-color: #fff; padding: 24px; }
        .card-back { background-color: #f0fff4; transform: rotateY(180deg); justify-content: space-between; }
        .card-category { font-size: 14px; color: #0052d9; margin-bottom: 8px; font-weight: 500; }
        .card-question { font-size: 20px; font-weight: 500; flex-grow: 1; display: flex; align-items: center; justify-content: center; text-align: center; }
        .card-answer-wrapper { flex-grow: 1; overflow-y: auto; }
        .card-answer { font-size: 15px; line-height: 1.7; }
        .card-footer { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 16px; margin-top: 16px; }
        .card-source { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 12px; margin-top: 12px; }
      </style>
    </head>
    <body>
      <div class="header">
        <h1>手动实现springboot自动装配 - 学习卡片</h1>
      </div>
      <div class="grid-container">
        
    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">理论</div>
          <div class="card-question">Spring Boot 自动装配的核心原理是什么？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">理论</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">Spring Boot 会根据类路径（classpath）中存在的 jar 包和类，来自动配置和生成相应的 Bean，并将其加载到 Spring 的 Context 中。这个过程通过 Spring 的条件配置来决定哪些 Bean 可以被配置，从而极大减少了手动配置的数量。</div>
          </div>
          <div class="card-source">来源: 自动装配的原理</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">在 Spring Boot 自动装配中，`spring.factories` 文件扮演了什么关键角色？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">`spring.factories` 文件用于注册自动配置类。Spring Boot 启动时，`EnableAutoConfigurationImportSelector` 会扫描 classpath 下所有的 `spring.factories` 文件，并加载其中 `org.springframework.boot.autoconfigure.EnableAutoConfiguration` 键下指定的配置类，从而实现自动化配置。</div>
          </div>
          <div class="card-source">来源: 自动装配的原理</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">特性</div>
          <div class="card-question">`@SpringBootApplication` 注解由哪三个核心注解组成？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">特性</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">`@SpringBootApplication` 是一个复合注解，它包含了三个核心注解：`@SpringBootConfiguration`（配置类）、`@EnableAutoConfiguration`（启用自动装配）和 `@ComponentScan`（扫描类）。</div>
          </div>
          <div class="card-source">来源: 注解</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">技术</div>
          <div class="card-question">在手动实现 Spring Boot 自动装配时，如何让一个自动配置类只有在满足特定条件时才生效？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">技术</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">可以使用条件注解，例如 `@Conditional` 或其派生注解如 `@ConditionalOnProperty`。这些注解允许你根据特定条件（如某个配置属性的值）来决定是否应用该自动配置。</div>
          </div>
          <div class="card-source">来源: 编写条件注解</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">`@EnableAutoConfiguration` 注解是如何触发自动装配流程的？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">该注解通过 `@Import` 导入了 `EnableAutoConfigurationImportSelector`。在 Spring 容器启动时，这个 `ImportSelector` 会被调用，它会去扫描 classpath 下所有 `spring.factories` 文件，找到并加载指定的自动配置类，从而完成 bean 的自动化配置。</div>
          </div>
          <div class="card-source">来源: 自动装配的原理</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">技术</div>
          <div class="card-question">手动创建一个 Spring Boot 自动配置模块时，首要步骤是什么？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">技术</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">首要步骤是创建一个新的模块或项目，用于编写自动配置的代码。这个模块通常会包含一个使用 `@Configuration` 注解标记的 `AutoConfiguration` 类和相关的配置。</div>
          </div>
          <div class="card-source">来源: 创建自动配置模块 和 编写自动配置类</div>
        </div>
      </div>
    </div>

      </div>
    </body>
    </html>
